<?php
class NRegistry{

	var $_registry_stack=array(array());
function &getInstance (){
        static $instance;
        if (!isset($instance)) {
            $c = __CLASS__;
            $instance = new $c;
        } // if
        return $instance;
    } 
	function __construct(){
	}
 function &setEntry($key, &$item) {
        $this->_registry_stack[0][$key] = &$item;
	return  $this->getEntry($key);
    }
    function &getEntry($key) {
        return $this->_registry_stack[0][$key];
    }
    function isEntry($key) {
        return ($this->getEntry($key) !== null);
    }
  
    function save() {
        array_unshift($this->_registry_stack, array());
        if (!count($this->_registry_stack)) {
            trigger_error('Registry lost');
        }
    }
    function restore() {
        array_shift($this->_registry_stack);
    }
    function pushToEntry($oArr,$entry,$key){
	$aRegVal = &$this->getEntry($entry);

	if (!$aRegVal) {
	$aRegVal=array();
	$aRegVal = &$this->setEntry($entry,$aRegVal);
	}

	foreach ($oArr as $oObj){
		$aRegVal[$oObj->$key]=$oObj;	
	}
    }
}
?>